<?php 
    require_once ('../connect.php');
    //接收参数
    $username = $_POST['username'];
    $date = $_POST['date'];
    //查找用户
    $user_sql = "select u_id from user where username = '$username'";
    $user_result = $con->query($user_sql);
    $user_row = $user_result->fetch_assoc();
    $user_id = $user_row['u_id'];
    //查找对应图片
    $photo_sql = "select photo_id,location from photo_wall where user_id = $user_id and photo_date = '$date'";
    $photo_result = $con->query($photo_sql);
    $photo_row = $photo_result->fetch_assoc();
    $photo_id = $photo_row['photo_id'];
    $location = $photo_row['location'];
    $photo_addr = strrchr($location, ".");
    $photo_addr = $username.$date.$photo_addr;
    //删除图片及更新数据库
    unlink("../picture/$photo_addr");
    $delete_sql = "delete from photo_wall where photo_id = $photo_id";
    if($con->query($delete_sql)){
        $flag = 0;
        echo json_encode($flag);
    }
    else{
        $flag = 1;
        echo json_encode($flag);
    }
?>